#include <bits/stdc++.h>
using namespace std;
const int M=2050;
const int N=1050;
int m,nx,ny,u,v;
struct Edge{
    int v,next;
}edge[M];
int cnt,head[N];
void init(){
    cnt=0;
    memset(head,-1,sizeof(head));
}
void addEdge(int u,int v){
    edge[cnt]=Edge{v,head[u]};
    head[u]=cnt++;
}
int mat[N];
bool vis[N];
bool dfs(int u){
    //printf("%d\n",u);
    for(int i=head[u];i!=-1;i=edge[i].next){
        int v=edge[i].v;
        if(!vis[v]){
            vis[v]=true;
            if(mat[v]==-1 || dfs(mat[v])){
                mat[v]=u;
                return true;
            }
        }
    }
    return false;
}
int hungary(){
    int res=0;
    memset(mat,-1,sizeof(mat));
    for(int u=1;u<=nx;u++){
        memset(vis,false,sizeof(vis));
        if(dfs(u)){
            res++;
        }
    }
    return res;
}
int main(void){
    while(~scanf("%d",&m) && m){
        init();
        scanf("%d%d",&nx,&ny);
        while(m--){
            scanf("%d%d",&u,&v);
            addEdge(u,v);
        }
        int ans=hungary();
        printf("%d\n",ans);
    }
    return 0;
}